// mypage/mechScope/mechScope.js



Page({
  /*页面的初始数据*/
  data: {
    pop_show: true,
    ju_list: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],
    value: [1],
    selectValue: 1,
    scope: ''
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that=this,ju_list=that.data.ju_list,value=that.data.value;
    wx.getStorage({
      key: 'scope',
      success:function(res){
        var scope=res.data,index=0;
        for(var i=0;i<ju_list.length;i++){
          if(ju_list[i]==scope){
            index=i
          }
        }
        value[0]=index
        that.setData({selectValue:index,scope:scope,value:value})
      }
    })
  },
  // 选择范围
  picker_change:function(e){
    var index = e.detail.value[0];
    this.setData({selectValue: index})
  },
  open_check:function(){
    this.setData({pop_show: !this.data.pop_show})
  },
  close_pop:function(){
    this.setData({pop_show: !this.data.pop_show})
  },
  confirm_num:function(){
    var that=this,val=that.data.selectValue,list=that.data.ju_list;
    that.setData({scope: list[val],pop_show: !that.data.pop_show})
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    //
    prevPage.setData({scope: list[val]});
    wx.setStorageSync('scope', list[val])
    wx.navigateBack({
      delta: 1
    });
  },
})